const API = require('../../../utils/api')
const app = getApp()

Page({

    /**
     * 页面的初始数据
     */
    data: {
        companyId: '',
        cardId: '',
        companyName:'',
        active: 0
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.setData({
            active: wx.getStorageSync('business_manage') ? 0 : 1,
            type: options.type,
            companyId: options.id,
            cardId: options.cardId,
            companyName: options.companyName
        })
    },
    navigationEvent (event) {
        if (this.data.active !== 0) return this.modeEvent()
        wx.navigateTo({ url: event.currentTarget.dataset.url })
    },
    modeEvent () {
        let active = this.data.active += 1;
        if (active > 3) {
            active = 0
            wx.setStorageSync('business_manage', true)
        }
        this.setData({active})
    },
    route:function(e){
        let index = parseInt(e.currentTarget.id)
        console.log( index )

        //特殊拦截
        if( index == 9 ){ //海报裂变
            wx.switchTab({
              url: '/pages/share/share',
            })
            return
        }

        let page = ''
        switch(index){
            case 1: //信息修改
                page = '/pages/park/company/edit/edit?type=2&id=' + this.data.companyId
                break
            case 2: //名片编辑
                page = '/pages/mine/park-manage/card/edit?cardId=' + this.data.cardId
                break
            case 6: //裂变团队
                page = '/pages/mine/share/share'
                break
            case 7: //企业主认证
                page = '/pages/mine/company-manage/authentication/authentication'
                break
            case 8: //金融服务
                page = '/pages/mine/park-manage/serve/serve'
                break
            case 10: //员工管理
                page = '/pages/mine/company-manage/staff/staff?id=' + this.data.companyId+'&companyName='+this.data.companyName
                break
        }
        wx.navigateTo({
          url: page,
        })

    }
})